#!/usr/bin/perl
$name = 'tandaica0612';
$namecompare = "toilatoi";
##
##IF .. ELSIF .. ELSE
##
#compare string : gt(>) , le(<=), ge(>=) , eq(==) , ne(!=) , lt(<)
if ($name lt $namecompare) {#neu' dieu` kien. nay` dung' thi` cac' dieu` kien. sau se~ khong duoc. xem xet
	print " '\$name' is tandaica0612\n";
}elsif($name lt $namecompare){
	print "$name nho hon $namecompare\n";
}
#		kq :
#		 '$name' is tandaica0612

##
##PERL khong co' switch .. case
##

##
##FOR LOOP
##
my @array;
# Old style C for loops
for (my $i = 0; $i < 3; $i++) {
	$array[$i] = $i;
}

# Iterating loops
for my $i (@array) {
	print "$i\n";
}
#		kq :
#		0
#		1
#		2

# Postfix for loops
print "$_\n" for @array;
#		kq :
#		0
#		1
#		2

#foreach loop
foreach $i (@array)		{
	print "$i\n";	# Print the item
}
#		kq:
#		0
#		1
#		2


##
##NEXT/LAST/CONTINUE/REDO
##

#* next skips to the end of the block and continues or restarts
#* redo jumps back to the beginning of the loop immediately
#* last skips to the end of the block and stops the loop from executing again
#* continue is run at the end of the block

$i = 0;
while ( 1 ) {
	last if $i > 3;
	$i++;
	next if $i == 1;
	redo if $i == 2;
}
continue {
	print "$i\n";
}
#		kq :
#		1
#		3
#		4


